<?php

use yii\db\Migration;

/**
 * Class m190602_061111_create_agent_account_log
 */
class m190602_061111_create_agent_account_log extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('{{%agent_account_log}}', [
            'id' => $this->primaryKey(),
            'agent_id' => $this->integer()->notNull()->comment('代理商编号'),
            'money' => $this->decimal(12, 2)->notNull()->comment('金额'),
            'create_time' => $this->integer()->notNull()->comment('创建时间'),
            'remark' => $this->string(128)->notNull()->comment('备注'),
        ]);
        $this->createIndex('fk_agent_account_log_agent1_idx', '{{%agent_account_log}}', ['agent_id']);
        try {
            $this->addForeignKey('fk_agent_account_log_agent1', '{{%agent_account_log}}', ['agent_id'], '{{%agent}}', ['id']);
        } catch (Exception $e) {
            Yii::error($e->getMessage());
        }
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%agent_account_log}}');
    }
}
